package com.xunce.xcworkservice.vo;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.List;

/**
 * @author yanlong.guo
 * 分页返回器
 */
@Data
public class IPageVo<T>{
    @Schema(description = "页码")
    private long pageNo;
    /**
     * 页大小
     */
    @Schema(description = "页大小")
    private long pageSize;
    /***
     * 总条数
     */
    @Schema(description = "总条数")
    private long total;
    /**
     * 数据集
     */
    @Schema(description = "数据集")
    private List<T> list;

    public IPageVo(List<T> list, long pageNo, long pageSize, long total) {
        this.list = list;
        if (list != null) {
            this.pageNo = (pageNo <= 0) ? 1 : pageNo;
            this.pageSize = (pageSize<=0) ? 10 : pageSize;
            this.total = total;
        }
    }

    public static <T> IPageVo<T> result(List<T> list, long pageNo, long pageSize, long total){
        return new IPageVo<>(list, pageNo, pageSize, total);
    }
}
